<?php

namespace app\admin\model;

use think\Model;


class StudentSemester extends Model
{

    

    

    // 表名
    protected $name = 'student_semesters';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
    ];
    

    
    public function getSemesterRuleList()
    {
        return ['day' => __('Day'), 'week' => __('Week')];
    }


    public function getSemesterRuleTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['semester_rule']) ? $data['semester_rule'] : '');
        $list = $this->getSemesterRuleList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function category()
    {
        return $this->belongsTo('app\admin\model\student\course\Category', 'category_id', 'category_id', [], 'LEFT')->setEagerlyType(0);
    }
}
